<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/hlht/hlhtTenantOpenApply.js"></script>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/laydate/laydate.css">
    <script src="${ctx}/libjs/plugins/laydate/laydate.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<br>' +
            '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>互联互通</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>发起申请</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">发起申请</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frmHlhtTenantOpenApply">
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">申请方运营商：</label>
                            <div class="col-sm-8">
                                <input class="form-control" hidden id="tenantCode" name="tenantCode" value="${tenant.tenantCode}">
                                <input class="form-control" value="${tenant.tenantName}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联运营商选择：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="hlhtOperatorId" name="hlhtOperatorId">
                                    <option checked>--请选择--</option>
                                    <c:forEach items="${hlhtTenantList}" var="hlhtTenant">
                                        <option value="${hlhtTenant.code}">${hlhtTenant.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联方向：</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="hlhtType" name="hlhtType">
                                    <option value="0" checked>反向（本方开放设备给互联方用户进行充电）</option>
                                    <option value="1">正向（本方用户启动互联方设备进行充电）</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联开始日期：</label>
                            <div class="col-sm-8">
                                <input class="form-control" id="beginDate" name="beginDate">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联结束日期：</label>
                            <div class="col-sm-8">
                                <input class="form-control" id="endDate" name="endDate">
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">附件：</label>
                            <div class="col-sm-8">
                                <div id="">
                                    <a id="contractFile" href="#"></a>
                                    <input type="hidden" id="fileName" name="fileName" value="">
                                    <input type="file" id="docfile" name="docfile"/>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">申请理由：</label>
                            <div class="col-sm-8">
                                <input id="remark" name="remark" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    // //日期范围限制
    var start = {
        elem: '#beginDate',
        format: 'YYYY-MM-DD',
        // theme: '#3195f0',
        // min: laydate.now(), //设定最小日期为当前日期
        // max: '2099-06-16 23:59:59', //最大日期
        istime: true,
        istoday: false,
        choose: function (datas) {
            $("#endDate").val("")
            end.min = datas
        }
    };
    var end = {
        elem: '#endDate',
        format: 'YYYY-MM-DD',
        // theme: '#3195f0',
        // min: laydate.now(),
        // max: '2099-06-16 23:59:59',
        istime: true,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);
    laydate.skin('molv');//皮肤


    $("#file1").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractImg1").attr("src", objUrl);
        }
    });

    $("#file2").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractImg2").attr("src", objUrl);
        }
    });

    $("#file3").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractImg3").attr("src", objUrl);
        }
    });

    $("#docfile").change(function () {
        if (this.files[0].size > 5 * 1024 * 1024) {
            parent.layer.msg("文件大小大于5M");
            return false;
        }
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractFile").attr("href", objUrl);
            var dotIndex = this.files[0].name.lastIndexOf(".");
            var fileName = this.files[0].name.substring(0, dotIndex);
            $("#fileName").val(fileName);
            $("#contractFile").text(objUrl.name);
        }
    });


    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }


    addHlhtTenantOpenApply.init();
</script>
</body>
</html>
